package com.wandon.ww.common.exception;

import com.wandon.ww.model.vo.common.Result;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandle {
    /**
     * 全局事件异常处理
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<T> handleException(Exception e) {
        return new Result<>(201,e.getMessage(),null);
    }

    /**
     * 只针对WwException异常的处理
     * @param e
     * @return
     */
    @ExceptionHandler(WwException.class)
    @ResponseBody
    public Result<T> handleException(WwException e) {
        return new Result<>(e.getCode(),e.getMessage(),null);
    }
}
